<?php

/**
 * @author gbfun <gbfun@163.com>  2017-09-16 20:03
 * http://www.wuweiyou.com
 */

abstract class wwy_db_table
{ 
    protected $_db_name = null;    //MySql中相当于数据库名，一般分成多个【不同数据库】时，【共用子类】需定义
    
    protected $_name = null;    //MySql中相当于表名，一般【具体子类】必须定义
    
    
    protected function _get_write_db()
    {
        return wwy_resource_container::get_write_db();
    }
    
    protected function _get_read_db()
    {
        return wwy_resource_container::get_db();
    }
    
    
    protected function __construct($config = array())
    {
        $this->_full_name = ($this->_db_name !== null) ?
        '`' . $this->_db_name . '`.`' . $this->_name . '`' :
        '`' . $this->_name . '`';
    
    }    
    
    public function get_page_data($total_item_count, $options = array())
    {
        //var_dump($options); exit();
        
        $page_item_count  = $options['item_count'];
        $current_page_num = $options['page_num'];  
        $page_range_count = $options['page_range'];
            
        $page_handler = wwy_resource_container::get_page_handler();
        $page_data = $page_handler->get_page_data($total_item_count, $page_item_count, $current_page_num, $page_range_count);
    
        return $page_data;
    }
}
